﻿
using Xacml.Core.Interfaces;
using Xacml.Core.Runtime;
using System.Globalization;

namespace Xacml.Core.Runtime.Functions
{
  public class StringNormalizeToLowerCase : FunctionBase
  {
    public override string Id
    {
      get
      {
        return "urn:oasis:names:tc:xacml:1.0:function:string-normalize-to-lower-case";
      }
    }

    public override IDataType Returns
    {
      get
      {
        return (IDataType) DataTypeDescriptor.String;
      }
    }

    public override IDataType[] Arguments
    {
      get
      {
        return new IDataType[1]
        {
          (IDataType) DataTypeDescriptor.String
        };
      }
    }

    public override EvaluationValue Evaluate(EvaluationContext context, params IFunctionParameter[] args)
    {
      return new EvaluationValue((object) this.GetStringArgument(args, 0).ToLower(CultureInfo.InvariantCulture), (IDataType) DataTypeDescriptor.String);
    }
  }
}
